package springXmlAffir.Service.impl;

import org.springframework.stereotype.Service;
import springXmlAffir.Mapper.AccountMapper;
import springXmlAffir.Service.AccountService;
import springXmlAffir.pojo.Account;

import javax.annotation.Resource;

/**
 * @author cc
 * @date 2021/8/16 16:42
 * @Description
 */

@Service
public class AccountServiceXmlImpl implements AccountService {

    @Resource
    AccountMapper accountMapper;
    public int addAccount(Account account) {
        int i = accountMapper.addAccount(account);
        return i;
    }

    public int updateAccount(String name, Double money) {
        return accountMapper.updateAccount(name,money);
    }

    public int transMoney(String name, double money, String newname) {
        int i = accountMapper.updateAccountMoney(name, money    *(-1));
        System.out.println(i > 0 ? name+"转账成功" : name+"转账失败");

        int j = accountMapper.updateAccountMoney(newname, money);
        System.out.println(j > 0 ? newname+"收款成功" : newname+"转收款失败");
        System.out.println(100/0);

        return 0;
    }
}
